<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <select name="" id="myselect">

        <option value="price">低价</option>
        <option value="distance">距离</option>
    </select>
    <script>
         var arr = [
            {name:"肯德基",price:100,distance:100},
            {name:"必胜客",price:200,distance:500},
            {name:"华莱士",price:50,distance:1000}
        ]
        var myselect = document.getElementById('myselect');
        myselect.onchange = function(){
            console.log(this.value)
            var value = this.value;
            arr.sort(function(a,b){
            return a[value]-b[value];// 对象的某个属性是变量，不能使用点，只能使用[]
           
        }) 
        
            console.log(arr);
        }
    </script>
</body>
</html>